//+--------------------------------------------------------------------------------
//| Copyright (c) 2012 - 2013 ### an.vuongngocduy
//| This file is a part of Compact Game Engine (CGE)
//+--------------------------------------------------------------------------------
#ifndef __CGE_LIST_H__
#define __CGE_LIST_H__

#include "cgeCommons.h"

namespace cge
{
	namespace std
	{
		//! Base list template
		template<class TVal>
		class List
		{
		public:
			//! Default constructor
			List(){}
			
			
			//! Destructor
			virtual ~List(){}

			
			//! Return number of elements currently held in list
			u32 Count() const
			{
				return this->count();
			}
			
			
			//! Get object at specified position
			TVal Get(u32 idx) const
			{
				return this->get(idx);
			}

			
			//! Set object at specified position
			void Set(u32 idx, const TVal& val)
			{
				this->set(idx, val);
			}

	
			//! Add new object to the beginning of list
			void PushFront(const TVal& val)
			{
				return this->insert(0, val);
			}

			
			//! Add new object to the end of list
			void PushBack(const TVal& val)
			{
				return this->insert(size(), val);
			}

			
			//! Insert new object into list at specified position
			void Insert(u32 idx, const TVal& val)
			{
				return this->insert(idx, val);
			}

			
			//! Delete the first object in list
			void PopFront()
			{
				this->remove(0);
			}

			
			//! Delete the last object in list
			void PopBack()
			{
				this->remove(size() - 1);
			}

			
			//! Delete object at specified postion in list
			void Remove(u32 idx)
			{
				this->remove(idx);
			}


			//! Clear out the content of list
			void Clear()
			{
				this->clear();
			}


		protected:
			//-- Internal calls. Must be implemented --//
			virtual u32 count() const = 0;
			
			virtual TVal get(u32 idx) const = 0;

			virtual void set(u32 idx, const TVal& val) = 0;

			virtual void insert(u32 idx, const TVal& val) = 0;

			virtual void remove(u32 idx) = 0;

			virtual void clear() = 0;
		};
	}
}

#endif//__CGE_LIST_H__